﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Android.App;
using Android.Content;
using Android.OS;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.Media;
using Android.Graphics;
using Android.Locations;
using AndroidText = Android.Text;
using Android.Content.Res;
using Android.Support.V4.App;

namespace MWC.NetcampCheckin
{
    [BroadcastReceiver]
    public class FeedbackNotification : BroadcastReceiver
    {
        public override void OnReceive(Context context, Intent intent)
        {
            try
            {
                Intent NetcampFeedback = new Intent(context, typeof(NetcampFeedback));
                TaskStackBuilder stackBuilder = TaskStackBuilder.Create(context);
                stackBuilder.AddParentStack(Java.Lang.Class.FromType(typeof(NetcampFeedback)));
                stackBuilder.AddNextIntent(NetcampFeedback);
                PendingIntent pendingIntent = stackBuilder.GetPendingIntent(0, (int)PendingIntentFlags.UpdateCurrent);

                NotificationCompat.Builder nBuilder = new NotificationCompat.Builder(context)
                .SetSmallIcon(Resource.Drawable.Icon)
                .SetContentText("Oceń nasze spotkanie :)")
                .SetContentTitle("Ankieta na koniec spotkania")
                .SetContentIntent(pendingIntent)
                .SetAutoCancel(true);

                NotificationManager notificationManager = (NotificationManager)context.GetSystemService(Context.NotificationService);
                notificationManager.Notify(1, nBuilder.Build());
            }
            catch(Exception e)
            {
                MWCApp.LogDebug(e);
            }
        }
    }
}